<template>
  <!-- 打分记录详情 -->
  <div class="app-container">
    <el-descriptions title="辅导员信息" :column="4" size="medium ">
      <el-descriptions-item label="辅导员姓名">{{queryParams.clrName}}</el-descriptions-item>
      <el-descriptions-item label="辅导员教工号">{{queryParams.clrTno}}</el-descriptions-item>
      <el-descriptions-item label="考核总分数">{{queryParams.clrExamineScoringMonads[0].sumScore}}</el-descriptions-item>
    </el-descriptions>
    <el-table
      :data="queryParams.clrExamineScoringMonads[0].fields"
      border
      :span-method="objectSpanMethod"
    >
      <!-- <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="序号" align="center" type="index" />-->
      <el-table-column
        label="指标分类名称"
        align="center"
        :show-overflow-tooltip="true"
        prop="classifyName"
        width="150"
      />
      <el-table-column label="指标名称" align="center" prop="name" :show-overflow-tooltip="true" />
      <el-table-column label="考核要点" align="center" prop="econtent">
        <template slot-scope="{row}">
          <el-popover trigger="hover">
            <div  v-html="row.econtent">
            </div>
          <div slot="reference">
            <span v-html="row.econtent" size="medium"></span>
          </div>
        </el-popover>
        </template>
      </el-table-column>
      <el-table-column label="赋分办法" align="center" prop="scoringWay">
        <template slot-scope="{ row }">
          <el-popover trigger="hover">
            <div  v-html="row.scoringWay">
            </div>
          <div slot="reference">
            <span v-html="row.scoringWay" size="medium"></span>
          </div>
        </el-popover>
        </template>
      </el-table-column>

      <el-table-column label="打分" align="center" prop="score" width="60"></el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  name: "Examinemonad",
  dicts: ["clr_exam_systype"],
  data() {
    return {
      // 遮罩层
      loading: true,
      indexArray: [],
      // 查询参数
      queryParams: {
      },
      // 表单参数
      form: {}
    };
  },
  watch: {
    $route (to, from) {
      console.log(to, from)
      // this.渲染数据的函数()
      this.queryParams = this.$route.params
    }
  },
  created() {
    this.queryParams = this.$route.params;
    console.log(this.$route.params, "this.$route.params.id");
  },
  mounted() {
    let count = 0;
    for (let rowIndex = 0; rowIndex < this.queryParams.clrExamineScoringMonads[0].fields.length; ) {
      this.indexArray.push(rowIndex);
      count = this.getRows(
        rowIndex,
        this.queryParams.clrExamineScoringMonads[0].fields[rowIndex].classifyName
      );
      rowIndex += count;
    }
  },
  methods: {
    cutout(cellValue) {
      console.log(cellValue, "cut");
      return cellValue.innerHTML;
    },
    objectSpanMethod({ row, column, rowIndex, columnIndex }) {
      if (columnIndex === 0) {
        let rowCount = 0;
        if (this.indexArray.includes(rowIndex)) {
          rowCount = this.getRows(rowIndex, row.classifyName);
          return {
            rowspan: rowCount,
            colspan: 1
          };
        } else {
          return {
            rowspan: 0,
            colspan: 0
          };
        }
      }
    },
    getRows(rowIndex, classifyName) {
      let count = 0;
      for (let i = rowIndex; i < this.queryParams.clrExamineScoringMonads[0].fields.length; i++) {
        if (this.queryParams.clrExamineScoringMonads[0].fields[i].classifyName === classifyName) {
          count++;
        } else {
          break;
        }
      }
      return count;
    }
  }
};
</script>
